﻿using WebApiClient;
using WebApiClient.Attributes;

namespace Spark.WeiXinSdk.App
{
    public interface IWxAppApi : IHttpApi
    {
        /// <summary>
        /// 获取微信授权Token
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="secret"></param>
        /// <param name="code"></param>
        /// <param name="grant_type"></param>
        /// <see cref="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317851&token=&lang=zh_CN"/>
        /// <returns></returns>
        [HttpGet("https://api.weixin.qq.com/sns/oauth2/access_token")]
        [JsonReturn]
        ITask<AppToken> GetToken(string appid, string secret, string code, string grant_type = "authorization_code");

        /// <summary>
        /// 刷新AccessToken
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="refresh_token"></param>
        /// <param name="grant_type"></param>
        /// <returns></returns>
        [HttpGet("https://api.weixin.qq.com/sns/oauth2/refresh_token")]
        [JsonReturn]
        ITask<AppToken> RefreshToken(string appid, string refresh_token, string grant_type = "refresh_token");

        /// <summary>
        /// 获取微信用户基础信息
        /// </summary>
        /// <param name="access_token">授权凭据</param>
        /// <param name="openid">微信用户Id</param>
        /// <see cref="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317853&token=&lang=zh_CN"/>
        /// <returns></returns>
        [HttpGet("https://api.weixin.qq.com/sns/userinfo")]
        [JsonReturn]
        ITask<UserInfo> GetUserInfo(string access_token, string openid);
    }
}